$(function(){

	$("body #foot").load("footer.html");

});
function CommonUtil() {
	var com = new Object();
	com = {
		basePath:function () {
			var url = window.location.href;
			if(url.indexOf("1724s691b9")!=-1){
				url = "http://1724s691b9.imwork.net/express";
			} else if(url.indexOf("xiaonatech")!=-1){
				url = "http://oa.xiaonatech.com/express";
			} else {
				url = "http://exp.lbt56.cn/express";
				// url = "http://localhost:8082/express";
			}
			return url;
		},
		/**
		 * 判断 数据是否为空
		 * @param tmp
		 * @returns {boolean}
		 */
		isNull: function (tmp) {
			if (!tmp || tmp == null || tmp == undefined || tmp == "" || tmp.length == 0) {
				return true;
			} else {
				return false;
			}
		},
		/**
		 * 获取文件路径
		 */
		getObjectURL: function (file) {
			// 建立一個可存取到該file的url
			var url = null;
			if (window.createObjectURL != undefined) { // basic
				url = window.createObjectURL(file);
			} else if (window.URL != undefined) { // mozilla(firefox)
				url = window.URL.createObjectURL(file);
			} else if (window.webkitURL != undefined) { // webkit or chrome
				url = window.webkitURL.createObjectURL(file);
			}
			return url;
		},
		//验证文件大小
		checkSize: function (file) {
			var fileSize = file.files[0].size / 1024, filemaxsize = 1024 * 5;//5M
			var filename = file.value;
//			var filetypes =[".jpg",".png",".pdf"];
			var filetypes = /(.[.]bmp)$|(.[.]gif)$|(.[.]jpg)$|(.[.]pdf)$|(.[.]png)$|(.[.]jpeg)$|(.[.]xlsx)$|(.[.]xls)$/i;
			if (!filetypes.test(filename)) {
				var errorinfo = "只支持bmp,gif,jpg,png,pdf,jpeg格式文件，请重新上传";
				layer.alert(errorinfo);
				return false;
			}
			//验证文件的大小
			if (fileSize > filemaxsize) {
				layer.alert("文件大小不能大于" + filemaxsize / 1024 + "M！");
				return false;
			}
			return true;
		},
		//判断是否Android手机端
		isMobileByAndroid: function () {//true为PC端，false为手机端
			var userAgentInfo = navigator.userAgent;
			// var mobileAgents = [ "Android", "iPhone", "SymbianOS", "Windows Phone", "iPad","iPod"];
			var mobile_flag = false;
			//根据userAgent判断是否是手机
			// for (var v = 0; v < mobileAgents.length; v++) {
			if (userAgentInfo.indexOf("Android") > 0) {
				mobile_flag = true;
				// break;
			}
			// }
			return mobile_flag;
		},
		isMobileByIos: function () {
			var u = navigator.userAgent;
			var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
			return !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
		},
		iosDateFormat: function (time) {
			// 解决IOS上无法从dateStr parse 到Date类型问题
			if (!this.isMobileByAndroid() && typeof time === "string") {
				if (time.indexOf(".") > -1) {
					// 有些日期接口返回带有.0。
					time = time.substring(0, time.indexOf("."));
				}
				// 解决IOS上无法从dateStr parse 到Date类型问题
				time = time.replace(/-/g, '/').replace("T", " ");
			}
			return time;
		},
		//格式化时间戳日期
		formatDate: function (time) {
			var now = new Date(this.iosDateFormat(time));
			var year = now.getFullYear(),
				month = now.getMonth() > 8 ? (now.getMonth() + 1) : "0" + (now.getMonth() + 1),
				date = now.getDate() > 9 ? now.getDate() : "0" + now.getDate(),
				hour = now.getHours() > 9 ? now.getHours() : "0" + now.getHours(),
				minute = now.getMinutes() > 9 ? now.getMinutes() : "0" + now.getMinutes(),
				second = now.getSeconds() > 9 ? now.getSeconds() : "0" + now.getSeconds();
			return year + "/" + month + "/" + date + " " + hour + ":" + minute + ":" + second;
		},
		dateFormat: function (time, fmt) {
			var date = new Date(this.iosDateFormat(time));
			var o = {
				"M+": date.getMonth() > 8 ? (date.getMonth() + 1) : "0" + (date.getMonth() + 1),     //月份
				"d+": date.getDate() > 9 ? date.getDate() : "0" + date.getDate(),                    //日
				"h+": date.getHours() > 9 ? date.getHours() : "0" + date.getHours(),                 //小时
				"m+": date.getMinutes() > 9 ? date.getMinutes() : "0" + date.getMinutes(),           //分
				"s+": date.getSeconds() > 9 ? date.getSeconds() : "0" + date.getSeconds(),           //秒
				"q+": Math.floor((date.getMonth() + 3) / 3), //季度
				"S": date.getMilliseconds()             //毫秒
			};
			if (/(y+)/.test(fmt))
				fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
			for (var k in o)
				if (new RegExp("(" + k + ")").test(fmt))
					fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
			return fmt;
		},
		addDate: function (date, days) {
			var c = this;
			if (days == undefined || days == '') {
				days = 1;
			}
			var date = new Date(this.iosDateFormat(date));
			date.setDate(date.getDate() + days);
			var month = date.getMonth() + 1;
			var day = date.getDate();
			return date.getFullYear() + '/' + c.getFormatDate(month) + '/' + c.getFormatDate(day);
		},
		// 日期月份/天的显示，如果是1位数，则在前面加上'0'
		getFormatDate: function (arg) {
			if (arg == undefined || arg == '') {
				return '';
			}
			var re = arg + '';
			if (re.length < 2) {
				re = '0' + re;
			}
			return re;
		},
		calculateDay: function(sDate1) {
			//当前时间
			var sDate2 = new Date();

			var dateSpan,
				iDays;
			sDate1 = Date.parse(sDate1);
			// sDate2 = Date.parse(sDate2);
			dateSpan = sDate2 - sDate1;
			dateSpan = Math.abs(dateSpan);
			iDays = Math.floor(dateSpan / (24 * 3600 * 1000));
			return iDays
		}
	}
	return com;
}